package com.ruoyi.zxjd.demeanor.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zxjd.demeanor.domain.DemeanorProgress;
import com.ruoyi.zxjd.demeanor.service.IDemeanorProgressService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查看记录Controller
 * 
 * @author lcc
 * @date 2021-03-15
 */
@Controller
@RequestMapping("/demeanor/progress")
public class DemeanorProgressController extends BaseController
{
    private String prefix = "demeanor/progress";

    @Autowired
    private IDemeanorProgressService demeanorProgressService;

    @RequiresPermissions("demeanor:progress:view")
    @GetMapping()
    public String progress()
    {
        return prefix + "/progress";
    }

    /**
     * 查询查看记录列表
     */
    @RequiresPermissions("demeanor:progress:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DemeanorProgress demeanorProgress)
    {
        startPage();
        List<DemeanorProgress> list = demeanorProgressService.selectDemeanorProgressList(demeanorProgress);
        return getDataTable(list);
    }

    /**
     * 导出查看记录列表
     */
    @RequiresPermissions("demeanor:progress:export")
    @Log(title = "查看记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DemeanorProgress demeanorProgress)
    {
        List<DemeanorProgress> list = demeanorProgressService.selectDemeanorProgressList(demeanorProgress);
        ExcelUtil<DemeanorProgress> util = new ExcelUtil<DemeanorProgress>(DemeanorProgress.class);
        return util.exportExcel(list, "progress");
    }

    /**
     * 新增查看记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存查看记录
     */
    @RequiresPermissions("demeanor:progress:add")
    @Log(title = "查看记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DemeanorProgress demeanorProgress)
    {
        return toAjax(demeanorProgressService.insertDemeanorProgress(demeanorProgress));
    }

    /**
     * 修改查看记录
     */
    @GetMapping("/edit/{progressId}")
    public String edit(@PathVariable("progressId") Long progressId, ModelMap mmap)
    {
        DemeanorProgress demeanorProgress = demeanorProgressService.selectDemeanorProgressById(progressId);
        mmap.put("demeanorProgress", demeanorProgress);
        return prefix + "/edit";
    }

    /**
     * 修改保存查看记录
     */
    @RequiresPermissions("demeanor:progress:edit")
    @Log(title = "查看记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DemeanorProgress demeanorProgress)
    {
        return toAjax(demeanorProgressService.updateDemeanorProgress(demeanorProgress));
    }

    /**
     * 删除查看记录
     */
    @RequiresPermissions("demeanor:progress:remove")
    @Log(title = "查看记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(demeanorProgressService.deleteDemeanorProgressByIds(ids));
    }
}
